<?php
error_reporting(0);
session_start();
include '../comm/config.php';
include '../comm/checkpostandget.php';
include_once '../comm/wjt.php';
$tag="center";

$name=trim($_POST['ddusername']); 
$pwd=trim($_POST['password']); 
$md5pwd=md5($pwd);
$sj= date("Y-m-d H:i:s");

if($name==""||$pwd=="")
{
    header('Location: error.php?id=0');
    exit;
}


$link = mysql_connect($dbserver, $dbuser, $dbpass);
if (!$link) {
     die(ERR_DB);
}
mysql_select_db($dbname);
mysql_query("set names utf8");
$q = "SELECT * FROM ".$BIAOTOU."user where ddusername='".$name."'";
$rs = mysql_query($q);
$total = mysql_num_rows($rs);
if($total==0)
{
	header('Location: error.php?id=3');
	exit;
}
else
{
	if(UC==1){
	    include '../data/config.inc.php';
        include '../uc_client/client.php';
	    $uc_name=iconv("utf-8","utf-8",$name);
        $ucresult = uc_user_edit($uc_name,'',$pwd,'',1);
		if($ucresult<=0){
		    header('Location: error.php?id=3');
	        exit;
	    }
	}
	$up = "update ".$BIAOTOU."user set ddpassword='".$md5pwd."' where ddusername='".$name."'";
	mysql_query($up);
	$mymsg="密码重置成功，现在您可以用您新设置的密码登录了。<br><br><a href=login.php  class=redlink>用户登录</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=../index.php class=redlink>返回首页</a>";
    
}
mysql_close($link);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<title>找回密码 - 用户中心</title>
<link href="../css/usercss.css" rel="stylesheet" type="text/css">
<link href="../template/<?=MOBAN?>/css/common.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="../js/jquery.js"></script>
</head>
<body>
<?php
include("../template/".MOBAN."/header.tpl.php");
?>
<?php
include("../template/".MOBAN."/nav.tpl.php");
?> 
<div id="maincenter">
  <table width="800" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="50" align="left">&nbsp;</td>
  </tr>
  <tr>
    <td height="50" align="center"><img src="../images/step3.gif" alt="找回密码第三步" width="637" height="31" /></td>
  </tr>
  <tr>
    <td height="50" align="center"></td>
  </tr>
  <tr>
    <td height="50" align="center" style="font-size:14px"><?=$mymsg?></td>
  </tr>
</table>
</div>
<?php
include("../template/".MOBAN."/footer.tpl.php");
?>
</body>
</html>